import { Address, Hex, zeroAddress } from 'viem'
import { describe, expect, it } from 'vitest'
import { CLPositionConfig } from '../../../types'
import { encodeCLPositionManagerMintCalldata } from './mint'

describe('encodeCLPositionManagerMintCalldata', () => {
  it('should correctly encode mint call data', () => {
    const positionConfig: CLPositionConfig = {
      poolKey: {
        currency0: '0x8FaE29D9Fc8eC94097Acd977fC5B5134406D409c' as Address,
        currency1: '0xe61AaC040dD88A85EE00BAa861FaEaddF1DC043C' as Address,
        poolManager: '0x969D90aC74A1a5228b66440f8C8326a8dA47A5F9' as Address,
        fee: 10000,
        hooks: zeroAddress,
        parameters: {
          tickSpacing: 200,
          hooksRegistration: {},
        },
      },
      tickLower: -16800,
      tickUpper: 2800,
    }
    const liquidity = 7999999999999999865782269n
    const recipient = '0xECcDeE7240A57d0190ab17BAC20f2695EbAb1c19' as Address
    const amount0Max = 4358793934808120209964501n
    const amount1Max = 2203025013947674970738582n
    const deadline = 115792089237316195423570985008687907853269984665640564039457584007913129639935n
    const hookData = '0x' as Hex

    const result = encodeCLPositionManagerMintCalldata(
      positionConfig,
      liquidity,
      recipient,
      amount0Max,
      amount1Max,
      deadline,
      hookData
    )

    expect(result).toBe(
      '0xdd46508f0000000000000000000000000000000000000000000000000000000000000040ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002020d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000008fae29d9fc8ec94097acd977fc5b5134406d409c000000000000000000000000e61aac040dd88a85ee00baa861faeaddf1dc043c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000969d90ac74a1a5228b66440f8c8326a8da47a5f900000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000c80000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbe600000000000000000000000000000000000000000000000000000000000000af0000000000000000000000000000000000000000000069e10de76676cfffffffd000000000000000000000000000000000000000000039b02b15343f5aec7fdd500000000000000000000000000000000000000000001d28239adcaa447b6cf96000000000000000000000000eccdee7240a57d0190ab17bac20f2695ebab1c1900000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000008fae29d9fc8ec94097acd977fc5b5134406d409c000000000000000000000000e61aac040dd88a85ee00baa861faeaddf1dc043c'
    )
  })
})
